package com.shortlink.controller;

import com.shortlink.service.ILinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

@RestController
@RequestMapping("/jump")
@Api(tags = "跳转模块")
public class JumpController {
    @Autowired
    ILinkService iLinkService;

    /**
     * 短链接跳转原始链接
     */
    @GetMapping("/{short-uri}")
    @ApiOperation("跳转链接")
    public void jump(@PathVariable("short-uri") String shortUri, ServletRequest request, ServletResponse response) {
        iLinkService.jump(shortUri, request, response);
    }

    @GetMapping("/notFound")
    @ApiOperation("跳转失败")
    public String notFound(){
        return "not found";
    }


}
